<template>
	<view class="box">
		
		<view class="search_box">

          <u-search bg-color="#fff" :show-action="false" placeholder="搜索感兴趣厨师" @search='to' v-model="params.name"></u-search>
		  
		</view>
		
		<view class="list_box">
			
			<view class="info_box" v-for="(item,index) in list" :key="index" @click="$project.toPath('/pages/chef/info?id='+item.id)">
				
				<image class="img" :src="item.images"></image>
				
				<view class="c_box">
					<view class="flex">
						<view class="title">{{item.name}}</view>
					    <view class="level">{{item.level}}{{item.zw}}</view>
					</view>
					<view class="num_box flex">
						<view>服务费: {{item.fw}}元</view>
						<view class="num">(已包含 {{item.num}} 道加工费)</view>
					</view>
					
					<view class="label_box">
						<view class="label" v-for="(items,indexs) in item.labeljson" :key="indexs">
							{{items.name}}
						</view>
					</view>
					
					<view class="site_box flex">
						<u-icon name="map-fill"></u-icon>
						<view>{{item.site}}</view>
					</view>
					
				</view>
				
			</view>
			
		</view>
		
		<view class="bitmap" v-if="emptyShow">
			<image src="../../static/img/no_content.png" mode="aspectFit"></image>
			<view class="gray_font fs-13">
				暂无
			</view>
		</view>
		
		
	</view>
</template>

<script>
	
	export default{
		data(){
			return{
				keyword:'',
				cate:[],
				current:0,
				params:{page:1,limit:10,name:''},
				list:[],
				total:0,
				emptyShow:false
				
			}
		},
		onShow() {
			
		},
		onLoad() {
		
	
		this.getList();
		   	
		},
		methods:{
			to(){
				this.getList();
			},
			change(e){
				console.log(e);
				this.current=e;
				this.params.cate_id=this.cate[e].id;
				this.getList();
			},
			
			getCate(){
				this.$get(this.$api.cateList,{},res=>{
					let {code,data} = res.data;
					
					if(code==1){
						data.unshift({id:0,name:'全部'});
						this.cate=data;
					}
					
				});
			},
			getList() {
				this.params.page = 1;
				this.$get(this.$api.chefList, this.params, res => {
					let data = res.data;
			
					if (!data.data.data || data.data.data.length < 1) {
						this.emptyShow = true;
					} else {
						this.emptyShow = false;
					}
			
					this.list = data.data.data;
					this.total = data.data.total;
				});
			}
		},
		onReachBottom() {
			if (this.list.length < this.total) {
				this.params.page++;
				this.$get(this.$api.chefList, this.params, res => {
					let data = res.data;
					data.data.data.forEach(ress => {
						this.list.push(ress);
					});
				});
			}
		},
	}
</script>

<style lang="scss" scoped>
	/deep/ .u-tab-item{
		background-color: transparent !important;
		font-size: 28rpx !important;
	}
	.box{
		min-height: 100vh;
		background-color: #F6F6F6;
		box-sizing: border-box;
		padding: 0 20rpx;
	}
	.search_box{
		
		box-sizing: border-box;
		padding: 30rpx 0 0 0;
	}
	.tab_box{
		margin-top: 20rpx;
	}
	.list_box{
		box-sizing: border-box;
		padding: 30rpx 0rpx;
	}
	.info_box{
		border-radius: 15rpx;
		background-color: white;
		margin-bottom: 20rpx;
		box-sizing: border-box;
		padding: 20rpx;
		display: flex;
		align-items: center;
	}
	.img{
		width:160rpx;
		height: 160rpx;
		border-radius: 50%;
		margin-right: 40rpx;
	}
	.c_box{
		
	}
	.flex{
		display: flex;
		align-items: center;
	}
	.title{
		font-size: 34rpx;
	}
	.num_box{
		font-size: 28rpx;
		margin-top: 15rpx;
	}
	.num{
		font-size: 24rpx;
		color: #A1A1A1;
		margin-left: 15rpx;
	}
	.level{
		border: 1rpx solid #EF8200;
		color: #EF8200;
		box-sizing: border-box;
		padding: 1rpx 10rpx;
		border-radius: 15rpx;
		font-size: 24rpx;
		margin-left: 20rpx;
	}
	.b_box{
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-size: 26rpx;
		color: #978E8C;
	}
	.label_box{
		display: flex;
		align-items: center;
		flex-wrap: wrap;
	}
	.label{
		font-size: 24rpx;
		margin: 15rpx 10rpx 0 0;
		background-color:#F7ECE4;
		color:#EF8200;
		box-sizing: border-box;
		padding: 6rpx 20rpx;
		border-radius: 10rpx;
	}
	.site_box{
		margin-top: 15rpx;
		font-size: 26rpx;
	}
	.bitmap {
		margin-top: 10vh;
		text-align: center;
	}
</style>